package org.ucas.faker.web.controller.graph;

import java.io.Console;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.ucas.faker.web.annotation.Registry;
import org.ucas.faker.web.controller.BaseController;
import org.ucas.faker.web.dto.CarryDto;
import org.ucas.faker.web.dto.ResponseDto;
import org.ucas.faker.web.fetcher.FetchReqBuilder;
import org.ucas.faker.web.fetcher.FetchRequest;
import org.ucas.faker.web.fetcher.FetchResult;
import org.ucas.faker.web.service.graph.Graph8Service;
import org.ucas.faker.web.service.graph.SpecialGraphAndMapService;
import org.ucas.faker.web.service.Visualization.entity.VisualParam;
import org.ucas.faker.web.service.Visualization.json.JsonUtil;
import org.ucas.faker.web.service.fishbone.FishboneService;
import org.ucas.faker.web.service.fishbone.FishboneSimpleService;
import org.ucas.faker.web.service.heatmap.HeatmapByTreeService;
import org.ucas.faker.web.service.heatmap.HeatmapService;
import org.ucas.faker.web.utils.fishbone.FishboneResult;
import org.ucas.faker.web.utils.model.Heatmap;

import com.alibaba.fastjson.JSONObject;

/**
 * Created by Wang Chong on 17-7-10.
 */
@RestController
public class SpecialGraphController extends BaseController {

  @Autowired
  private SpecialGraphAndMapService SpecialGraphAndMapService;

  @Autowired
  Graph8Service g8Serv;
  
  @Autowired 
  private HeatmapService heatmapService;

  @Autowired
  private HeatmapByTreeService heatmapByTreeService;
  
  @Autowired 
  private FishboneService fishboneService;
  
//added by Chen Li
  @Autowired private FishboneSimpleService fishboneSimpleService;
  
  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "1001",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/1001",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents1001() {


    //获取flowID放到数据库中使用，使用方法：currentFlowId();
    //mybatis写一个xml语句，然后sql ref include即可
    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_1001_x_Axis();
    List<String> graph_1001_x_Axis = mylist.get(0);
    List<String> graph_1001_y_value = mylist.get(1);
    result.put("xAxis", graph_1001_x_Axis);
    result.put("yValue", graph_1001_y_value);
    //文字描述
    List<String> comment = mylist.get(2);
    result.put("comment", comment);
    //文字描述
    return result;
  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "2001",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/2001",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents2001() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_2001(currentDepotId());
    List<String> graph_2001_x_Axis = mylist.get(0);
    List<String> graph_2001_y_value = mylist.get(1);
    result.put("xAxis", graph_2001_x_Axis);
    result.put("graph_2001_y_value", graph_2001_y_value);
    return result;
  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "3001",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/3001",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents3001() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_30011();
    List<String> graph_3001_x_Axis = mylist.get(0);
    List<String> graph_3001_y_value = mylist.get(1);
    result.put("xAxis", graph_3001_x_Axis);
    result.put("graph_3001_y_value", graph_3001_y_value);
    return result;
  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "4001",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/4001",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents4001() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_4001_x_Axis();
    List<String> graph_4001_x_Axis = mylist.get(0);
    List<String> graph_4001_y_value = mylist.get(1);
    result.put("xAxis", graph_4001_x_Axis);
    result.put("yValue", graph_4001_y_value);
    return result;
  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "6001",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/6001",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents6001() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_6001();
    List<String> graph_6001_x_Axis = mylist.get(0);
    List<String> graph_6001_y_company1 = mylist.get(1);
    List<String> graph_6001_y_company2 = mylist.get(2);
    List<String> graph_6001_y_company3 = mylist.get(3);
    List<String> graph_6001_y_company4 = mylist.get(4);
    List<String> graph_6001_y_company5 = mylist.get(5);
    List<String> graph_6001_y_company6 = mylist.get(6);
    List<String> graph_6001_y_company7 = mylist.get(7);
    List<String> graph_6001_y_company8 = mylist.get(8);
    List<String> graph_6001_y_company9 = mylist.get(9);
    List<String> graph_6001_y_company10 = mylist.get(10);
    List<String> graph_6001_y_companyname = mylist.get(11);

    result.put("xAxis", graph_6001_x_Axis);
    result.put("graph_6001_y_company1", graph_6001_y_company1);
    result.put("graph_6001_y_company2", graph_6001_y_company2);
    result.put("graph_6001_y_company3", graph_6001_y_company3);
    result.put("graph_6001_y_company4", graph_6001_y_company4);
    result.put("graph_6001_y_company5", graph_6001_y_company5);
    result.put("graph_6001_y_company6", graph_6001_y_company6);
    result.put("graph_6001_y_company7", graph_6001_y_company7);
    result.put("graph_6001_y_company8", graph_6001_y_company8);
    result.put("graph_6001_y_company9", graph_6001_y_company9);
    result.put("graph_6001_y_company10", graph_6001_y_company10);
    result.put("graph_6001_y_companyname", graph_6001_y_companyname);

    return result;
  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5001",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5001",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5001_x_Axis(currentDepotId());
    List<String> graph_5001_x_Axis = mylist.get(0);
    List<String> graph_5001_y_value = mylist.get(1);
    result.put("xAxis", graph_5001_x_Axis);
    result.put("yValue", graph_5001_y_value);
    //文字描述
    List<String> comment = mylist.get(2);
    result.put("comment", comment);
    //文字描述
    return result;
  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5002",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5002",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5002() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5002(currentDepotId());
    List<String> graph_5002_x_Axis = mylist.get(0);
    List<String> graph_5002_y_value = mylist.get(1);
    result.put("xAxis", graph_5002_x_Axis);
    result.put("yValue", graph_5002_y_value);
    //文字描述
    List<String> comment = mylist.get(2);
    result.put("comment", comment);
    //文字描述
    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5003",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5003",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5003() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5003(currentDepotId());
    List<String> graph_5003_x_Axis = mylist.get(0);
    List<String> graph_5003_y_apply = mylist.get(1);
    List<String> graph_5003_y_grant = mylist.get(2);
    result.put("xAxis", graph_5003_x_Axis);
    result.put("yapply", graph_5003_y_apply);
    result.put("ygrant", graph_5003_y_grant);
    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5004",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5004",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5004() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5004();
    List<String> graph_5004_x_Axis = mylist.get(0);
    List<String> graph_5004_y_fmzl = mylist.get(1);
    List<String> graph_5004_y_syxxzl = mylist.get(2);
    List<String> graph_5004_y_wgsjzl = mylist.get(3);
    result.put("xAxis", graph_5004_x_Axis);
    result.put("graph_5004_y_fmzl", graph_5004_y_fmzl);
    result.put("graph_5004_y_syxxzl", graph_5004_y_syxxzl);
    result.put("graph_5004_y_wgsjzl", graph_5004_y_wgsjzl);
    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5005",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5005",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5005() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5005();
    List<String> graph_5005_x_Axis = mylist.get(0);
    List<String> graph_5005_y_yxzl = mylist.get(1);
    List<String> graph_5005_y_wxzl = mylist.get(2);
    List<String> graph_5005_y_sczdzl = mylist.get(3);
    result.put("xAxis", graph_5005_x_Axis);
    result.put("graph_5005_y_yxzl", graph_5005_y_yxzl);
    result.put("graph_5005_y_wxzl", graph_5005_y_wxzl);
    result.put("graph_5005_y_sczdzl", graph_5005_y_sczdzl);
    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5006",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5006",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5006() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5006();
    List<String> graph_5006_x_Axis = mylist.get(0);
    List<String> graph_5006_y_value = mylist.get(1);
    result.put("xAxis", graph_5006_x_Axis);
    result.put("graph_5006_y_value", graph_5006_y_value);
    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5007",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5007",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5007() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5007();
    List<String> graph_5007_x_Axis = mylist.get(0);
    List<String> graph_5007_y_company1 = mylist.get(1);
    List<String> graph_5007_y_company2 = mylist.get(2);
    List<String> graph_5007_y_company3 = mylist.get(3);
    List<String> graph_5007_y_company4 = mylist.get(4);
    List<String> graph_5007_y_company5 = mylist.get(5);
    List<String> graph_5007_y_company6 = mylist.get(6);
    List<String> graph_5007_y_company7 = mylist.get(7);
    List<String> graph_5007_y_company8 = mylist.get(8);
    List<String> graph_5007_y_company9 = mylist.get(9);
    List<String> graph_5007_y_company10 = mylist.get(10);
    List<String> graph_5007_y_companyname = mylist.get(11);

    result.put("xAxis", graph_5007_x_Axis);
    result.put("graph_5007_y_company1", graph_5007_y_company1);
    result.put("graph_5007_y_company2", graph_5007_y_company2);
    result.put("graph_5007_y_company3", graph_5007_y_company3);
    result.put("graph_5007_y_company4", graph_5007_y_company4);
    result.put("graph_5007_y_company5", graph_5007_y_company5);
    result.put("graph_5007_y_company6", graph_5007_y_company6);
    result.put("graph_5007_y_company7", graph_5007_y_company7);
    result.put("graph_5007_y_company8", graph_5007_y_company8);
    result.put("graph_5007_y_company9", graph_5007_y_company9);
    result.put("graph_5007_y_company10", graph_5007_y_company10);
    result.put("graph_5007_y_companyname", graph_5007_y_companyname);

    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5008",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5008",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5008() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5008();
    List<String> graph_5008_x_Axis = mylist.get(0);
    List<String> graph_5008_y_fmzl = mylist.get(1);
    List<String> graph_5008_y_syxxzl = mylist.get(2);
    List<String> graph_5008_y_wgsjzl = mylist.get(3);
    result.put("xAxis", graph_5008_x_Axis);
    result.put("graph_5008_y_fmzl", graph_5008_y_fmzl);
    result.put("graph_5008_y_syxxzl", graph_5008_y_syxxzl);
    result.put("graph_5008_y_wgsjzl", graph_5008_y_wgsjzl);
    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5009",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5009",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5009() {

    HashMap<String,List<String>> result = new HashMap<>();
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5009();
    List<String> graph_5009_x_Axis = mylist.get(0);
    List<String> graph_5009_y_America = mylist.get(1);
    List<String> graph_5009_y_Japan = mylist.get(2);
    List<String> graph_5009_y_Europe = mylist.get(3);
    List<String> graph_5009_y_Korea = mylist.get(4);
    List<String> graph_5009_y_China = mylist.get(5);
    result.put("xAxis", graph_5009_x_Axis);
    result.put("graph_5009_y_America", graph_5009_y_America);
    result.put("graph_5009_y_Japan", graph_5009_y_Japan);
    result.put("graph_5009_y_Europe", graph_5009_y_Europe);
    result.put("graph_5009_y_Korea", graph_5009_y_Korea);
    result.put("graph_5009_y_China", graph_5009_y_China);

    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5010",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5010",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5010() {

    HashMap<String,List<String>> result = new HashMap<>();
    //目前数据库字段没有PTV，待补充，此为示查询方法，数据库补充字段后,换为select_5010()
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5010_noptv();
    List<String> graph_5010_x_Axis = mylist.get(0);
    List<String> graph_5010_y_America = mylist.get(1);
    List<String> graph_5010_y_Japan = mylist.get(2);
    List<String> graph_5010_y_Europe = mylist.get(3);
    List<String> graph_5010_y_Korea = mylist.get(4);
    List<String> graph_5010_y_China = mylist.get(5);
    result.put("xAxis", graph_5010_x_Axis);
    result.put("graph_5010_y_America", graph_5010_y_America);
    result.put("graph_5010_y_Japan", graph_5010_y_Japan);
    result.put("graph_5010_y_Europe", graph_5010_y_Europe);
    result.put("graph_5010_y_Korea", graph_5010_y_Korea);
    result.put("graph_5010_y_China", graph_5010_y_China);

    return result;
  }


  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5011",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5011",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5011() {

    HashMap<String,List<String>> result = new HashMap<>();
    //目前数据库字段没有PTV，待补充，此为示查询方法，数据库补充字段后,换为select_5010()
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5011_noptv();
    List<String> graph_5011_x_Axis = mylist.get(0);
    List<String> graph_5011_y_tech1 = mylist.get(1);
    List<String> graph_5011_y_tech2 = mylist.get(2);
    List<String> graph_5011_y_tech3 = mylist.get(3);
    List<String> graph_5011_y_tech4 = mylist.get(4);
    List<String> graph_5011_y_tech5 = mylist.get(5);
    List<String> graph_5011_y_tech6 = mylist.get(6);
    List<String> graph_5011_y_tech7 = mylist.get(7);
    List<String> graph_5011_y_tech8 = mylist.get(8);
    result.put("xAxis", graph_5011_x_Axis);
    result.put("graph_5011_y_tech1", graph_5011_y_tech1);
    result.put("graph_5011_y_tech2", graph_5011_y_tech2);
    result.put("graph_5011_y_tech3", graph_5011_y_tech3);
    result.put("graph_5011_y_tech4", graph_5011_y_tech4);
    result.put("graph_5011_y_tech5", graph_5011_y_tech5);
    result.put("graph_5011_y_tech6", graph_5011_y_tech6);
    result.put("graph_5011_y_tech7", graph_5011_y_tech7);
    result.put("graph_5011_y_tech8", graph_5011_y_tech8);
    //transposition test
    List<String> graph_5011_y_1= new LinkedList<>();
    List<String> graph_5011_y_2= new LinkedList<>();
    List<String> graph_5011_y_3= new LinkedList<>();
    List<String> graph_5011_y_4= new LinkedList<>();
    List<String> graph_5011_y_5= new LinkedList<>();
    graph_5011_y_1.add(graph_5011_y_tech1.get(1));
    graph_5011_y_1.add(graph_5011_y_tech2.get(1));
    graph_5011_y_1.add(graph_5011_y_tech3.get(1));
    graph_5011_y_1.add(graph_5011_y_tech4.get(1));
    graph_5011_y_1.add(graph_5011_y_tech5.get(1));
    graph_5011_y_1.add(graph_5011_y_tech6.get(1));
    graph_5011_y_1.add(graph_5011_y_tech7.get(1));
    graph_5011_y_1.add(graph_5011_y_tech8.get(1));

    graph_5011_y_2.add(graph_5011_y_tech1.get(2));
    graph_5011_y_2.add(graph_5011_y_tech2.get(2));
    graph_5011_y_2.add(graph_5011_y_tech3.get(2));
    graph_5011_y_2.add(graph_5011_y_tech4.get(2));
    graph_5011_y_2.add(graph_5011_y_tech5.get(2));
    graph_5011_y_2.add(graph_5011_y_tech6.get(2));
    graph_5011_y_2.add(graph_5011_y_tech7.get(2));
    graph_5011_y_2.add(graph_5011_y_tech8.get(2));

    graph_5011_y_3.add(graph_5011_y_tech1.get(3));
    graph_5011_y_3.add(graph_5011_y_tech2.get(3));
    graph_5011_y_3.add(graph_5011_y_tech3.get(3));
    graph_5011_y_3.add(graph_5011_y_tech4.get(3));
    graph_5011_y_3.add(graph_5011_y_tech5.get(3));
    graph_5011_y_3.add(graph_5011_y_tech6.get(3));
    graph_5011_y_3.add(graph_5011_y_tech7.get(3));
    graph_5011_y_3.add(graph_5011_y_tech8.get(3));

    graph_5011_y_4.add(graph_5011_y_tech1.get(4));
    graph_5011_y_4.add(graph_5011_y_tech2.get(4));
    graph_5011_y_4.add(graph_5011_y_tech3.get(4));
    graph_5011_y_4.add(graph_5011_y_tech4.get(4));
    graph_5011_y_4.add(graph_5011_y_tech5.get(4));
    graph_5011_y_4.add(graph_5011_y_tech6.get(4));
    graph_5011_y_4.add(graph_5011_y_tech7.get(4));
    graph_5011_y_4.add(graph_5011_y_tech8.get(4));

    graph_5011_y_5.add(graph_5011_y_tech1.get(1));
    graph_5011_y_5.add(graph_5011_y_tech2.get(1));
    graph_5011_y_5.add(graph_5011_y_tech3.get(1));
    graph_5011_y_5.add(graph_5011_y_tech4.get(1));
    graph_5011_y_5.add(graph_5011_y_tech5.get(1));
    graph_5011_y_5.add(graph_5011_y_tech6.get(1));
    graph_5011_y_5.add(graph_5011_y_tech7.get(1));
    graph_5011_y_5.add(graph_5011_y_tech8.get(1));

    result.put("graph_5011_y_1", graph_5011_y_1);
    result.put("graph_5011_y_2", graph_5011_y_2);
    result.put("graph_5011_y_3", graph_5011_y_3);
    result.put("graph_5011_y_4", graph_5011_y_4);
    result.put("graph_5011_y_5", graph_5011_y_5);

    return result;
  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "5012",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/5012",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents5012() {

    HashMap<String,List<String>> result = new HashMap<>();
    //目前数据库字段没有PTV，待补充，此为示查询方法，数据库补充字段后,换为select_5010()
    List< List <String> > mylist = SpecialGraphAndMapService.graph_5012_noptv();
    List<String> graph_5012_x_Axis = mylist.get(0);
    List<String> graph_5012_y_tech1 = mylist.get(1);
    List<String> graph_5012_y_tech2 = mylist.get(2);
    List<String> graph_5012_y_tech3 = mylist.get(3);
    List<String> graph_5012_y_tech4 = mylist.get(4);
    List<String> graph_5012_y_tech5 = mylist.get(5);
    List<String> graph_5012_y_tech6 = mylist.get(6);
    List<String> graph_5012_y_tech7 = mylist.get(7);
    List<String> graph_5012_y_tech8 = mylist.get(8);
    result.put("xAxis", graph_5012_x_Axis);
    result.put("graph_5012_y_tech1", graph_5012_y_tech1);
    result.put("graph_5012_y_tech2", graph_5012_y_tech2);
    result.put("graph_5012_y_tech3", graph_5012_y_tech3);
    result.put("graph_5012_y_tech4", graph_5012_y_tech4);
    result.put("graph_5012_y_tech5", graph_5012_y_tech5);
    result.put("graph_5012_y_tech6", graph_5012_y_tech6);
    result.put("graph_5012_y_tech7", graph_5012_y_tech7);
    result.put("graph_5012_y_tech8", graph_5012_y_tech8);
    //transposition test
    List<String> graph_5012_y_1= new LinkedList<>();
    List<String> graph_5012_y_2= new LinkedList<>();
    List<String> graph_5012_y_3= new LinkedList<>();
    List<String> graph_5012_y_4= new LinkedList<>();
    List<String> graph_5012_y_5= new LinkedList<>();
    graph_5012_y_1.add(graph_5012_y_tech1.get(1));
    graph_5012_y_1.add(graph_5012_y_tech2.get(1));
    graph_5012_y_1.add(graph_5012_y_tech3.get(1));
    graph_5012_y_1.add(graph_5012_y_tech4.get(1));
    graph_5012_y_1.add(graph_5012_y_tech5.get(1));
    graph_5012_y_1.add(graph_5012_y_tech6.get(1));
    graph_5012_y_1.add(graph_5012_y_tech7.get(1));
    graph_5012_y_1.add(graph_5012_y_tech8.get(1));

    graph_5012_y_2.add(graph_5012_y_tech1.get(2));
    graph_5012_y_2.add(graph_5012_y_tech2.get(2));
    graph_5012_y_2.add(graph_5012_y_tech3.get(2));
    graph_5012_y_2.add(graph_5012_y_tech4.get(2));
    graph_5012_y_2.add(graph_5012_y_tech5.get(2));
    graph_5012_y_2.add(graph_5012_y_tech6.get(2));
    graph_5012_y_2.add(graph_5012_y_tech7.get(2));
    graph_5012_y_2.add(graph_5012_y_tech8.get(2));

    graph_5012_y_3.add(graph_5012_y_tech1.get(3));
    graph_5012_y_3.add(graph_5012_y_tech2.get(3));
    graph_5012_y_3.add(graph_5012_y_tech3.get(3));
    graph_5012_y_3.add(graph_5012_y_tech4.get(3));
    graph_5012_y_3.add(graph_5012_y_tech5.get(3));
    graph_5012_y_3.add(graph_5012_y_tech6.get(3));
    graph_5012_y_3.add(graph_5012_y_tech7.get(3));
    graph_5012_y_3.add(graph_5012_y_tech8.get(3));

    graph_5012_y_4.add(graph_5012_y_tech1.get(4));
    graph_5012_y_4.add(graph_5012_y_tech2.get(4));
    graph_5012_y_4.add(graph_5012_y_tech3.get(4));
    graph_5012_y_4.add(graph_5012_y_tech4.get(4));
    graph_5012_y_4.add(graph_5012_y_tech5.get(4));
    graph_5012_y_4.add(graph_5012_y_tech6.get(4));
    graph_5012_y_4.add(graph_5012_y_tech7.get(4));
    graph_5012_y_4.add(graph_5012_y_tech8.get(4));

    graph_5012_y_5.add(graph_5012_y_tech1.get(1));
    graph_5012_y_5.add(graph_5012_y_tech2.get(1));
    graph_5012_y_5.add(graph_5012_y_tech3.get(1));
    graph_5012_y_5.add(graph_5012_y_tech4.get(1));
    graph_5012_y_5.add(graph_5012_y_tech5.get(1));
    graph_5012_y_5.add(graph_5012_y_tech6.get(1));
    graph_5012_y_5.add(graph_5012_y_tech7.get(1));
    graph_5012_y_5.add(graph_5012_y_tech8.get(1));

    result.put("graph_5012_y_1", graph_5012_y_1);
    result.put("graph_5012_y_2", graph_5012_y_2);
    result.put("graph_5012_y_3", graph_5012_y_3);
    result.put("graph_5012_y_4", graph_5012_y_4);
    result.put("graph_5012_y_5", graph_5012_y_5);

    return result;
  }

//  /**
//   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
//   * @return
//   * @throws IOException
//   */
//  @Registry(code = "7002",subscriber = "WCH")
//  @RequestMapping(value = "/draw/graph/7002",method = RequestMethod.GET)
//  public HashMap<String,List<String>> listAllPatents7002() throws IOException {
//
//    HashMap<String,List<String>> result = new HashMap<>();
//    result=heatmapService.getHeatmap(currentDepotId()).getResult();
//    return result;
//  }

  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
 * @throws InstantiationException 
 * @throws IllegalAccessException 
   */
  //技术功效矩阵
  @Registry(code = "7001",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/7001",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatentsfem() throws IllegalAccessException, InstantiationException {

	  
    HashMap<String,List<String>> result = new HashMap<String,List<String>>();
    HashMap<String,List<Long>> callBackResult = new HashMap<>();
    //result= (HashMap<String, List<String>>) SpecialGraphAndMapService.graph_7001(currentDepotId()19);
    result= (HashMap<String, List<String>>) SpecialGraphAndMapService.graph_7001(currentDepotId());
    
    /*for(Entry<String, List<String>> entry : result.entrySet()) {
    	Iterator<Map.Entry<String, List<String>>> it= entry.
    	String key=entry.getKey();
    	List<String> val=entry.getValue();
    	
    }*/
    
    
    
    Iterator<Entry<String, List<String>>> iter = result.entrySet().iterator();
    while (iter.hasNext()) {
    	Map.Entry entry = (Map.Entry) iter.next();
    	String key = (String) entry.getKey();
    	List<String> val = (List<String>) entry.getValue();
    	if(key.contains("send")) {
    		List<Long> strToLong = new ArrayList<>();
    		for(String str : val) {
    			  long l = Long.parseLong(str);
    			  strToLong.add(l);
    			}
    		callBackResult.put(key, strToLong);
    		System.out.println("key:"+key+",strToLong:"+strToLong);
    		iter.remove();
    	}
    }
    
    
    graph_ids_map(callBackResult);
    //result= (HashMap<String, List<String>>) SpecialGraphAndMapService.graph_7001(currentDepotId());
	
	

    /*List<String> graph1 = result.get("value1");
    for(int i=0;i<graph1.size();i++)
      System.out.print(graph1.get(i)+",");
    System.out.println();
    List<String> graph2 = result.get("xlabel");
    for(int i=0;i<graph2.size();i++)
      System.out.print(graph2.get(i)+",");
    System.out.println();*/
    
    
    return result;

  }
  
  @RequestMapping(value = "/draw/graph/7001_callback", method = RequestMethod.POST)
  @ResponseBody
  public ResponseDto techAndEffCallBack(@RequestParam(value = "graph_message", required = true) String key,
		  @RequestParam(value = "graph_type", required = true) String graph_type){
	  callback_json(key);
	  graph_type(graph_type);
	  return ResponseDto.OK;
  } 
  
  
  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "2006",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/2006",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents2006() {
	
	HashMap<String,List<String>> result = new HashMap<>();
	//System.out.println("currentDepotId(): map:"+currentDepotId());
	List<List<String>> mylist = SpecialGraphAndMapService.graph_2006(currentDepotId());
	//List<List<String>> mylist = SpecialGraphAndMapService.graph_2006(currentDepotId());
	//xAxis：List内容：中国各个省份的名称
	List<String> xAxis = mylist.get(0);
	//yValue0：List内容：xAxis中各个省份对应的专利数量，要和xAxis的顺序一致
	List<String> yValue0 = mylist.get(1);
	result.put("xAxis", xAxis);
	result.put("yValue0", yValue0);
	System.out.println(yValue0);
    return result;
  }
  
  @RequestMapping(value = "/draw/graph/2006_callback", method = RequestMethod.POST)
  @ResponseBody
  public ResponseDto mapCallBack(@RequestParam(value = "graph_message", required = true) String cityName,
		  @RequestParam(value = "graph_type", required = true) String graph_type){
	  callback_json(cityName);
	  graph_type(graph_type);
	  return ResponseDto.OK;
  }
  
//***非通用图***
  
  
  
  @Registry(code = "7002",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/7002",method = RequestMethod.GET)
  public HashMap<String,Heatmap> listAllPatents7002() throws IOException {
	
	//HashMap<String,List<String>> result = new HashMap<>();
	//modified by Chen Li
	//result=heatmapService.getHeatmap(currentFlowId()).getResult();
	//result = heatmapByTreeService.getHeatmap(24).getResult();
	//result = heatmapByTreeService.getHeatmap(currentDepotId(), currentTreeId()).getResult();
	HashMap<String,Heatmap> result = new HashMap<>();
	  
	Heatmap heatMapResult = new Heatmap();
	heatMapResult = heatmapByTreeService.getHeatmap(currentDepotId(), currentTreeId());
	
	result.put("graph_7002_heatMapResult", heatMapResult);
	
	return result;
  }
  
  @RequestMapping(value = "/draw/graph/7002_callback", method = RequestMethod.POST)
  @ResponseBody
  public ResponseDto heatMapCallBack(@RequestParam(value = "graph_message", required = true) String list,
		  @RequestParam(value = "graph_type", required = true) String graph_type){
	  callback_json(list);
	  graph_type(graph_type);
	  return ResponseDto.OK;
  }
  
  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  //鱼骨图
  @Registry(code = "7003",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/7003",method = RequestMethod.GET)
  //public HashMap<String,List<Class>> listAllPatentsfishgraph() {
  public HashMap<String,FishboneResult> listAllPatentsfishgraph() {
	HashMap<String,FishboneResult> result = new HashMap<>();
	FishboneResult fishResult= new FishboneResult(); 
	fishResult = fishboneSimpleService.testSimple(currentDepotId(), currentTreeId());
	/*List<Line> lineList = new ArrayList<Line>();
	Line myline=new Line();
	myline.setStartPoint(new double[]{0.0, 0.0});
	myline.setEndPoint(new double[]{50,0});
	myline.setWidth(12);
	lineList.add(myline);
	Line myline1=new Line();
	myline1.setStartPoint(new double[]{0.0, 0.0});
	myline1.setEndPoint(new double[]{50,15});
	myline1.setWidth(12);
	lineList.add(myline1);
	
	List<Polygon> polygonList = new ArrayList<Polygon>();
	Polygon mypolygon=new Polygon();
	mypolygon.addPoint(new double[]{0.0, 0.0});
	Polygon mypolygon1=new Polygon();
	mypolygon1.addPoint(new double[]{60, 0.0});
	polygonList.add(mypolygon);
	polygonList.add(mypolygon1);
	
	List<Circle> circleList = new ArrayList<Circle>();
	Circle circle=new Circle();
	circle.setX(10);
	circle.setY(10);
	circle.setRadius(2);
	Circle circle1=new Circle();
	circle1.setX(10);
	circle1.setY(-10);
	circle1.setRadius(12);
	circleList.add(circle);
	circleList.add(circle1);
	
	List<Tag> tagList = new ArrayList<Tag>();
	Tag tag=new Tag();
	tag.setX(13);
	tag.setY(10);
	tag.setDirection("R");
	tag.setSize(14);
	tag.setText("第一个");
	Tag tag1=new Tag();
	tag1.setX(13);
	tag1.setY(-10);
	tag1.setDirection("R");
	tag1.setSize(14);
	tag1.setText("第二个");
	tagList.add(tag);
	tagList.add(tag1);
	
	fishResult.setLineList(lineList);
	fishResult.setPolygonList(polygonList);
	fishResult.setCircleList(circleList);
	fishResult.setTagList(tagList);*/
	//resultList.put(key, value)
	//result.put("graph_7003_tag", graph_7003_tag);
	result.put("graph_7003_fishResult", fishResult);
	
	//System.out.println("max value******:"+result.get("graph_7003_fishResult").getXmax());
	
    return result;
    
  }

  
  
  /**
   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
   * @return
   */
  @Registry(code = "2006test",subscriber = "WCH")
  @RequestMapping(value = "/draw/graph/2006test",method = RequestMethod.GET)
  public HashMap<String,List<String>> listAllPatents2007() {
	
	HashMap<String,List<String>> result = new HashMap<>();
	//List<List<String>> mylist = SpecialGraphAndMapService.graph_2006(currentDepotId());
	//xAxis：List内容：中国各个省份的名称
	//List<String> xAxis = mylist.get(0);
	//yValue0：List内容：xAxis中各个省份对应的专利数量，要和xAxis的顺序一致
	//List<String> yValue0 = mylist.get(1);
	
	List<String> xAxis = new ArrayList();
	//yValue0：List内容：xAxis中各个省份对应的专利数量，要和xAxis的顺序一致
	List<String> yValue0 = new ArrayList();
	 
	String []pro= {"北京","天津","上海","重庆","河北","河南","云南","辽宁","黑龙江","湖南","安徽","山东","新疆","江苏","浙江","江西","湖北","广西","甘肃","山西","内蒙古","陕西","吉林","福建","贵州","广东","青海","西藏","四川","宁夏","海南","台湾","香港","澳门"};
	for(int j=0;j<pro.length;j++) {
		xAxis.add(pro[j]);
		yValue0.add(String.valueOf(j));
	}
	
	result.put("xAxis", xAxis);
	result.put("yValue0", yValue0);
	System.out.println(yValue0);
    return result;
  }
//***非通用图***

//
//  /**
//   * 通过service获取相应的表项，以hashmap的形式整合返还给前端，xAxis、xValue、yAxis、yValue。。。。。。
//   * @return
//   */
//
//  @Registry(code = "7003",subscriber = "WCH")
//  @RequestMapping(value = "/draw/graph/7003",method = RequestMethod.GET)
//  //public HashMap<String,List<Class>> listAllPatentsfishgraph() {
//  public HashMap<String,FishboneResult> listAllPatentsfishgraph() {
//    HashMap<String,FishboneResult> result = new HashMap<>();
//
//
//    //modified by Chen Li
////		fishResult = fishboneService.test();
//    FishboneResult fishResult = fishboneSimpleService.testSimple(17);
//
//    List<Tag> graph_7003_tag = fishResult.getTagList();
//    List<Line> graph_7003_lineList = fishResult.getLineList();
//    List<Circle> graph_7003_circleList = fishResult.getCircleList();
//    HashMap<String,List<String>> resultList = new HashMap<>();
//    List<String> resulttagx = new ArrayList<String>();
//    List<String> resulttagy = new ArrayList<String>();
//    List<String> resulttagsize = new ArrayList<String>();
//    List<String> resulttagtext = new ArrayList<String>();
//    for(int i=0;i<graph_7003_tag.size();i++) {
//      //System.out.println("asasas"+graph_7003_tag.get(i).getX());
//      resulttagx.add(String.valueOf(graph_7003_tag.get(i).getX()));
//
//    }
//    for(int i=0;i<graph_7003_tag.size();i++) {
//      resulttagy.add(String.valueOf(graph_7003_tag.get(i).getY()));
//
//    }
//    for(int i=0;i<graph_7003_tag.size();i++) {
//      resulttagsize.add(String.valueOf(graph_7003_tag.get(i).getSize()));
//
//    }
//    for(int i=0;i<graph_7003_tag.size();i++) {
//      resulttagtext.add(String.valueOf(graph_7003_tag.get(i).getText()));
//
//    }
//
//    resultList.put("tagvaluex",resulttagx);
//    //resultList.put(key, value)
//    //result.put("graph_7003_tag", graph_7003_tag);
//    result.put("graph_7003_fishResult", fishResult);
//
//    return result;
//
//  }
  
  @RequestMapping(value = "/draw/graph/7003_callback", method = RequestMethod.POST)
  @ResponseBody
  public ResponseDto fishboneCallBack(@RequestParam(value = "graph_message", required = true) String list,
		  @RequestParam(value = "graph_type", required = true) String graph_type){
	  callback_json(list);
	  graph_type(graph_type);
	  return ResponseDto.OK;
  }


}
